package edu.objects;

import org.junit.*;

import junit.framework.TestCase;

public class LetterBagTest extends TestCase {
	
	@Before
	protected void setUp() throws Exception {
		super.setUp();
	}
	
	@Test
	public void testTake() {
		LetterBag bag = new LetterBag();
		//Take all letters.
		for (int i=0; i<100; i++) {
			System.out.print(bag.grabLetters(1));
			assertTrue(bag.getLettersRemaining()==99-i);
		}
		//test empty
		try {
			bag.grabLetters(1);
			fail("Bag is not emptying.");
		} catch (IllegalArgumentException e) {
			//ok
		}
		assertTrue(bag.getLettersRemaining()==0);
	}
	
	@Test
	public void testTrade() {
		System.out.println("\nTrading...\n");
		LetterBag bag = new LetterBag();
		assertTrue(bag.tradeLetters(new char[] {}).length==0);
		assertTrue(bag.getLettersRemaining()==100);
		char[] myletters = bag.grabLetters(7);
		System.out.println(myletters);
		myletters = bag.tradeLetters(myletters);
		System.out.println(myletters);
		
	}
}
	

